<template>
  <div class="shell">
    <ul class="nav">
      <li :class="ac === 1 ? 'active' : ''" id="logo">
        <a href="#" @click="ac = 1">
          <div class="icon">
            <div class="imageBox">
              <!-- <img src="./goat.jpg" alt=""> -->
            </div>
          </div>
          <div class="text">{{ user.username }}</div>
        </a>
      </li>
      <li :class="ac === 2 ? 'active' : ''">
        <a href="#home" @click="ac = 2">
          <div class="icon">
            <i class="iconfont icon-cangku"></i>
          </div>
          <div class="text">数据展示</div>
        </a>
      </li>
      <li :class="ac === 3 ? 'active' : ''">
        <a href="#theme" @click="ac = 3">
          <div class="icon">
            <i class="iconfont icon-zhuti_tiaosepan"></i>
          </div>
          <div class="text">用户分析</div>
        </a>
      </li>
      <li :class="ac === 4 ? 'active' : ''">
        <a href="#wallet" @click="ac = 4">
          <div class="icon">
            <i class="iconfont icon-qianbao"></i>
          </div>
          <div class="text">数据上传</div>
        </a>
      </li>
      <!-- <li :class="ac===5 ?'active':'' ">
				<a href="#picture" @click="ac=5">
					<div class="icon">
						<i class="iconfont icon-tupian"></i>
					</div>
					<div class="text">picture</div>
				</a>
			</li>
			<li :class="ac===6 ?'active':'' ">
				<a href="#code" @click="ac=6">
					<div class="icon">
						<i class="iconfont icon-erweima"></i>
					</div>
					<div class="text">QR code</div>
				</a>
			</li>
			<li :class="ac===7 ?'active':'' ">
				<a href="#authentication" @click="ac=7">
					<div class="icon">
						<i class="iconfont icon-dunpaibaoxianrenzheng"></i>
					</div>
					<div class="text">authentication</div>
				</a>
			</li>
			<li :class="ac===8 ?'active':'' ">
				<a href="#me" @click="ac=8">
					<div class="icon">
						<div class="imageBox">
							<img src="./goat.jpg" alt="">
						</div>
					</div>
					<div class="text">ME</div>
				</a>
			</li> -->
    </ul>
  </div>

  <section v-if="ac === 1">
    <User style="margin-right: 30%" />
  </section>
  <section v-if="ac === 2" class="sect">
    <Show />
  </section>
  <section v-if="ac === 3" class="sect">
    <div style="width: 300px; height: 100vh; flex: 2"></div>
    <Analysis style="flex: 10" />
  </section>
  <section v-if="ac === 4" class="sect"><Upload /></section>
  <!-- <section id="code">QR code</section>
	<section id="authentication">authentication</section>
	<section id="me">ME</section> -->
  <Ai />
</template>

<script setup>
import User from './user/user.vue';
import Show from './show/show.vue';
import Analysis from './analysis/analysis.vue';
import Upload from './upload/upload.vue';
import Ai from './ai/ai.vue';
import emitter from '@/utils/evenBus';

import { ref, reactive, onMounted } from 'vue';

const ac = ref(1);

const user = ref({
  username: ''
});

const handleSubmit = () => {
  const storedUser = JSON.parse(sessionStorage.getItem('user'));
  if (storedUser) {
    user.value.username = storedUser.username;
  }
};

onMounted(() => {
  handleSubmit();
  console.log('1');
  emitter.on('setname', (name, password) => {
    user.value.username = name;
  });
});
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  list-style: none;
  text-decoration: none;
  color: #60ffa0;
}

.shell {
  position: fixed;
  width: 84px;
  height: 100%;
  background: #000000;
  z-index: 9999;
  transition: width 0.5s;
  padding-left: 10px;
  overflow: hidden;

  ul {
    position: relative;
    height: 100vh;

    li {
      position: relative;
      padding: 5px;
      margin: 20px 0px;
    }

    a {
      position: relative;
      display: flex;
      white-space: nowrap;
      // color: aquamarine;
    }
  }

  .active {
    background: #e4e9f5;
    border-top-left-radius: 50px;
    border-bottom-left-radius: 50px;

    .icon {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      min-width: 60px;
      padding-left: 10px;
      height: 70px;
      color: #333;
      transition: 0.5s;
      color: rgb(255, 255, 255);

      i {
        font-size: 30px;
        z-index: 999;
      }
    }

    a .icon::before {
      content: '';
      position: absolute;
      inset: 5px;
      width: 60px;
      background: #000000;
      border-radius: 50%;
      transition: 0.5s;
      border: 7px solid #ffa117;
      box-sizing: border-box;
    }

    .text {
      position: relative;
      height: 70px;
      display: flex;
      align-items: center;
      font-size: 20px;
      color: #ffad32c1;
      padding-left: 15px;
      text-transform: uppercase;
      letter-spacing: 2px;
      transition: 0.5s;
    }
  }

  .active::before {
    content: '';
    position: absolute;
    top: -30px;
    right: 0;
    width: 30px;
    height: 30px;
    border-bottom-right-radius: 25px;
    box-shadow: 5px 5px 0 5px #e4e9f5;
    background: transparent;
  }

  .active::after {
    content: '';
    position: absolute;
    bottom: -30px;
    right: 0;
    width: 30px;
    height: 30px;
    border-top-right-radius: 25px;
    box-shadow: 5px -5px 0 5px #e4e9f5;
    background: transparent;
  }
}

.shell:hover {
  width: 300px;
}

.shell ul li:hover a .icon,
.shell ul li:hover a .text {
  color: #ffa117;
}

// .sect {
// 	width: 90%;
// 	height: 90vh;
// 	display: flex;

// 	/* 水平方向靠右对齐 */
// 	align-items: center;
// 	/* 垂直方向居中对齐 */

// 	/* 为了演示设置一个固定高度，实际中可根据需要调整 */
// 	border: 1px solid gray;
// 	/* 为了显示父元素范围添加边框 */
// }
section {
  position: relative;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  font: 900 100px '';
  color: #ffa21759;
  background: #e4e9f5;
}
</style>
